package com.cl.eb.controller;

import com.cl.eb.model.EbProduct;
import com.cl.eb.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;

@Controller
@RequestMapping("product")
public class ProductController {
    @Resource
    private ProductService productService;
    @RequestMapping("/detail")
    public String detail(Model model,int pid){
        System.out.println("进入ProductController的detail方法...pid："+pid);
        //Todo 1.调用service查询1该pid的商品详情
        EbProduct productDetail = productService.detail(pid);
        //Todo 2.绑定数据model
        model.addAttribute("productDetail",productDetail);
        //Todo 3.返回view
        return "product-view";//templates/product-view.html
    }
}
